﻿using System;
using System.Collections.Generic;
using FreeSql.DataAnnotations;

namespace App.Model.Main
{
    /// <summary>
    /// 系统用户
    /// </summary>
    //[Table(Name = "sys_user")]
    [Index("uk_{tablename}_Account", nameof(Account), true)]
    public class SysUser : EntityBase<int>
    {
        /// <summary>
        /// 登陆账号
        /// </summary>
        [Column(StringLength = 20, IsNullable = false)]
        public string Account { get; set; }

        /// <summary>
        /// 密码
        /// </summary>
        [Column(StringLength = 50, IsNullable = false)]
        public string Password { get; set; }

        /// <summary>
        /// 密码混淆码
        /// </summary>
        [Column(StringLength = 50, IsNullable = false)]
        public string Salt { get; set; }

        /// <summary>
        /// 权限id
        /// </summary>
        [JsonMap]
        [Column(MapType = typeof(string), StringLength = -2)]
        public List<int> RoleIds { get; set; }

        /// <summary>
        /// 默认子平台
        /// </summary>
        public int DefPlatform { get; set; }

        /// <summary>
        /// 子系统平台id
        /// </summary>
        [JsonMap]
        [Column(MapType = typeof(string), StringLength = -2)]
        public List<int> PlatformIds { get; set; }

        /// <summary>
        /// 真实姓名
        /// </summary>
        [Column(StringLength = 20, IsNullable = false)]
        public string RealName { get; set; }

        /// <summary>
        /// 昵称
        /// </summary>
        [Column(StringLength = 20)]
        public string NickName { get; set; }

        /// <summary>
        /// 头像
        /// </summary>
        [Column(StringLength = 200)]
        public string HeadIcon { get; set; }

        /// <summary>
        /// 0未知 1男 2女
        /// </summary>
        public int Gender { get; set; }

        /// <summary>
        /// 生日
        /// </summary>
        public DateTime? Birthday { get; set; }

        /// <summary>
        /// 手机号
        /// </summary>
        [Column(StringLength = 20, IsNullable = false)]
        public string MobilePhone { get; set; }

        /// <summary>
        /// 邮箱
        /// </summary>
        [Column(StringLength = 20)]
        public string Email { get; set; }

        /// <summary>
        /// 微信号
        /// </summary>
        [Column(StringLength = 20)]
        public string WeChat { get; set; }

        /// <summary>
        /// 是不是超级管理员
        /// </summary>
        public bool IsAdministrator { get; set; }

        /// <summary>
        /// 最后登录时间
        /// </summary>
        public DateTime? LastLoginTime { get; set; }

        /// <summary>
        /// 绑定账户id
        /// </summary>
        public int? UserId { get; set; }

        /// <summary>
        /// 用户身份
        /// </summary>
        public int? UserIdentity { get; set; }
    }
}


